package jmine.tec.services.utils.replace.transformation;

import jmine.tec.services.utils.replace.api.ServiceBlock;

public class RenameParameterTransformation extends AbstractTransformation {

    private final String oldParameter;

    private final String newParameter;

    public RenameParameterTransformation(String action, String name, String oldParameter, String newParameter) {
        super(action, name);
        this.oldParameter = oldParameter;
        this.newParameter = newParameter;
    }

    public void apply(ServiceBlock block) {
        block.getHeader().renameParameter(this.oldParameter, this.newParameter);
    }

    @Override
    public String toString() {
        return String.format("RenameParameter: %s.%s '%s' -> '%s'", this.action, this.name, this.oldParameter, this.newParameter);
    }
}
